{{left_sidebar_enabled,right_sidebar_enabled=True,False}}
{{extend 'layout.html'}}

{{if viewtext <>'':}}
<p>
{{=viewtext}}
</p>
{{pass}}

{{if quest['qtype'] != 'action':}}
<h1>Question</h1>
<p>{{=MARKMIN(quest['questiontext'])}}</p>

<h2>Answers</h2>
{{if quest['status'] == 'Resolved':}}
<p>Users have resolved that the correct answer is: </p>
<p>{{=quest['correctanstext']}}</p>
{{pass}}

<p>The analysis of all answers is shown below.  <INPUT TYPE=BUTTON onClick="parent.location='{{=URL('useranswers',args=[quest['id']])}}'" VALUE="Details"></p>
<table id='TabAnswers'>
				<thead>
					<tr>
						<th></th>
                        {{for item in lstanswers:}}
                        <th>{{=item}}</th>
                        {{pass}}
                    </tr>
                </thead>
                    <tbody>
                    <tr>
                        <th></th>
                        {{for item in lstnumanswers:}}
                        <td>{{=item}}</td>
                        {{pass}}
                    </tr>
                    </tbody>
                </table>


<p>This question has been answered {{=quest['totanswers']}} times. {{=numpass}} users passed on this question.  The current category is {{=quest['category']}}.</p>



{{if quest['status'] == 'Resolved':}}
{{if quest['answerreasons'] <> '':}}
<h2>Reasons</h2>
{{=MARKMIN(quest['answerreasons'])}}
{{=MARKMIN(quest['answerreason2'])}}
{{=MARKMIN(quest['answerreason3'])}}
{{pass}}
<h2>Challenge</h2>
<p>This question is resolved - if you think the answer is wrong you may wish to challenge </p>

<p><INPUT TYPE=BUTTON onclick="ajax('{{=URL('viewquest','challenge',args=quest['id'])}}', ['challreason'], 'target')" VALUE="Challenge">Reason: <input type="text" name="challreason" value="Enter reason for challenge" onfocus="if($(this).val() == 'Enter reason for challenge') $(this).val('')" onblur="if($(this).val() == '') $(this).val('Enter reason for challenge')"></p>
<p><INPUT TYPE=BUTTON onclick="ajax('{{=URL('viewquest','agree',args=[quest['id'],1])}}', ['quest'], 'target')" VALUE="Agree"><INPUT TYPE=BUTTON onclick="ajax('{{=URL('viewquest','agree',args=[quest['id'],0])}}', ['quest'], 'target')" VALUE="Disagree"></p>

{{else:}}
<h2>Status</h2>
<p>This question is currently {{=quest['status']}}.  You don't have the option to challenge or agree and disagree at present because there is no resolved answer. </p>
{{pass}}

<p><INPUT TYPE=BUTTON onClick="parent.location='{{=URL('answer','get_question',args=['quest'])}}'" VALUE="Next Question"><INPUT TYPE=BUTTON onclick="parent.location='{{=URL('submit','new_question',args=['action',quest['id']])}}'" VALUE="Linked Action"><INPUT TYPE=BUTTON onclick="parent.location='{{=URL('submit','new_question',args=['quest',quest['id']])}}'" VALUE="Linked Question"></p>

{{else:}}
<h1>Action</h1>
<p>{{=MARKMIN(quest['questiontext'])}}</p>

<h2>Status   <INPUT TYPE=BUTTON onClick="parent.location='{{=URL('useranswers',args=[quest['id']])}}'" VALUE="Details"></h2>
{{if quest['status'] != 'In Progress':}}
<p>This action is {{=quest['status']}} - if you think this is incorrect you may wish to challenge, you can also register your agreement or disagreement if you have not already done so.</p>

<p><INPUT TYPE=BUTTON onclick="ajax('{{=URL('viewquest','challenge',args=quest['id'])}}', ['challreason'], 'target')" VALUE="Challenge">Reason: <input id="challreason" name="challreason" type="text"  value="Enter reason for challenge" onfocus="if($(this).val() == 'Enter reason for challenge') $(this).val('')" onblur="if($(this).val() == '') $(this).val('Enter reason for challenge')" ></p>
 
{{else:}}

<p>This action is not yet agreed so you don't have the option to challenge at present. You can either go to the next action directly or register your agreement and assessment of the urgency and importance of the action by clicking on the appropriate buttons. </p>

{{pass}}

<p><INPUT TYPE=BUTTON onclick="ajax('{{=URL('viewquest','agree',args=[quest['id'],1])}}', ['quest'], 'target')" VALUE="Agree"><INPUT TYPE=BUTTON onclick="ajax('{{=URL('viewquest','agree',args=[quest['id'],0])}}', ['quest'], 'target')" VALUE="Disagree"></p>

<p><INPUT TYPE=BUTTON onClick="parent.location='{{=URL('answer','get_question',args=['action'])}}'" VALUE="Next Action"><INPUT TYPE=BUTTON onClick="parent.location='{{=URL('submit','new_question',args=['action'])}}'" VALUE="Create Action"> <INPUT TYPE=BUTTON onclick="parent.location='{{=URL('submit','new_question',args=['action',quest['id']])}}'" VALUE="Linked Action"></p>

{{pass}}


<div id="target"></div>

<h2>Urgency and importance</h2>

{{if quest['qtype'] != 'action':}}
{{if uqanswered:}}
<p>Here is how you and other people have rated the urgency and importance of the question so far.</p>
<table id='TabUrgency'>
				<thead>
					<tr>
						<th></th>
                        <th>Urgency</th>
                        <th>Importance</th>
                    </tr>
                </thead>
                    <tbody>
                    <tr>
                        <th>Overall</th>
                        <td>0 <input id="urgslide" type = "range" name="urgslider"  min="0"    max="10" value="{{=quest['urgency']}}" step="1" disabled /> 10</td>
                        <td>0 <input id="urgslide" type = "range" name="urgslider"  min="0"    max="10" value="{{=quest['importance']}}" step="1" disabled/> 10</td>
                    </tr>
                    <tr>
                        <th>You</th>
                        <td>0 <input id="urgslide" type = "range" name="urgslider"  min="0"    max="10" value="{{=uqurg}}" step="1" disabled /> 10</td>
                        <td>0 <input id="urgslide" type = "range" name="urgslider"  min="0"    max="10" value="{{=uqimp}}" step="1" disabled/> 10</td>
                    </tr>
                    </tbody>
                </table>

{{else:}}
<p>Here is how other people rated the urgency and importance of this question. </p>
<table id='TabUrgency'>
				<thead>
					<tr>
						<th></th>
                        <th>Urgency</th>
                        <th>Importance</th>
                    </tr>
                </thead>
                    <tbody>
                    <tr>
                        <th>Overall</th>
                        <td>0 <input id="urgslide" type = "range" name="urgslider"  min="0"    max="10" value="{{=quest['urgency']}}" step="1" disabled /> 10</td>
                        <td>0 <input id="urgslide" type = "range" name="urgslider"  min="0"    max="10" value="{{=quest['importance']}}" step="1" disabled/> 10</td>
                    </tr>
                    </tbody>
                </table>
{{pass}}
{{else:}}
{{if uqanswered:}}
<p>Here is how you and other people have rated the urgency and importance of the action so far.  You can adjust your assessment and resubmit as often as you like but only your latest opinion counts in the overall assessment.</p>
{{else:}}
<p>You haven't rated this action yet - other people rated it as follows. Please record your assessment using the form below:</p>  
{{pass}}
<table id='TabUrgency'>
				<thead>
					<tr>
						<th></th>
                        <th>Urgency</th>
                        <th>Importance</th>
                        <th></th>
                    </tr>
                </thead>
                    <tbody>
                    <tr>
                        <th>Overall</th>
                        <td><input id="urgslide" type = "range" name="urgslider"  min="0"    max="10" value="{{=quest['urgency']}}" step="1" disabled /></td>
                        <td><input id="urgslide" type = "range" name="impslider"  min="0"    max="10" value="{{=quest['importance']}}" step="1" disabled/></td>
                        <td></td>
                    </tr>
                    <tr>
                        <th>You</th>
                        <td><input id="urgslide2" type = "range" name="urgslider2"  min="0"    max="10" value="{{=uqurg}}" step="1"/></td>
                        <td><input id="impslide2" type = "range" name="impslider2"  min="0"    max="10" value="{{=uqimp}}" step="1"/></td>
                        <td><INPUT TYPE=BUTTON onclick="ajax('{{=URL('viewquest','urgency',args=[quest['id']])}}', ['urgslider2', 'impslider2'], 'urgupdate')" VALUE="Update"></td>
                    </tr>
                    </tbody>
                </table>

<div id="urgupdate"></div> 

{{pass}}

<h2>Comments</h2>
<p><INPUT TYPE=BUTTON onclick="parent.location='{{=URL('comments',args=[quest['id']])}}'" VALUE="View & Add Comments"></p>

{{block left_sidebar}}
{{include 'newleftside.html'}}

{{end}}

{{if auth.user <> None:}} 
{{if quest['qtype'] != 'action':}}

<script>

gvChartInit();
jQuery(document).ready(function(){


   jQuery('#TabAnswers').gvChart({
	chartType: 'PieChart',
        hidetable: false,
	gvSettings: {
		vAxis: {title: 'Answers'},
		hAxis: {title: ''},
		width: 600,
		height: 300
		}});  
});

</script>
{{pass}}
{{pass}}




 




